package cn.cosmosx.base.calc;

import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;

/**
 * 贷款数据计算参数
 */
@Getter
@Setter
public class Param {
    private final static BigDecimal monthTimes = new BigDecimal("12");
    /**
     * 贷款金额
     */
    private BigDecimal loanAmount;
    /**
     * 贷款年利率
     */
    private BigDecimal yearRate;
    /**
     * 贷款期限（月）
     */
    private int loanPeriods;
    /**
     * 首期还款日
     */
    private LocalDate startRepaymentDate = LocalDate.now();

    public BigDecimal getMonthRate() {
        return LoanCalculator.fromMetadata(yearRate.divide(monthTimes, 8, RoundingMode.HALF_EVEN), 8);
    }
}

